﻿Public Class EditUnit
    Public l As New Label
    Private Sub btnok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnok.Click
        cmdp.Parameters("@name") = txtname.Text
        cmdp.Parameters("@detail") = txtdetail.Text
        If txtname.Text.Trim = "" Then
            MessageBox.Show("ឈ្មោះអង្គភាព ឬការិយាល័យមិនងាចទទេរបានតេ")
            txtname.Focus()
            Exit Sub
        End If
        If l.Text = "" Then
            cmdp.ExecuteNonQuery("INSERT INTO [Ministry] (MinistryName,Detail) VALUES(@name,@detail)")
        Else
            cmdp.Parameters("@id") = l.Text
            cmdp.ExecuteNonQuery("UPDATE [Ministry] SET MinistryName=@name,Detail=@detail WHERE MinistryID=@id")
        End If
        Me.DialogResult = Windows.Forms.DialogResult.OK
    End Sub

    Private Sub EditUnit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class